
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module owlController
* @author: Hjava
* @description: 对 owl 的封装
* @since: 2019-05-21 17:35:34
*/
var constant_1 = __webpack_require__(/*! _util/constant */ "./src/core/utils/constant.ts");
var userData_1 = __webpack_require__(/*! _util/userData */ "./src/core/utils/userData.ts");
var clientInfo_1 = __webpack_require__(/*! ./clientInfo */ "./src/core/utils/clientInfo.ts");
var OwlController = /** @class */ (function () {
    function OwlController() {
        this._owl = null;
        this._extendObject = null;
    }
    OwlController.prototype.init = function (extendObject) {
        if (true) {
            this._extendObject = extendObject;
            this._owl = __webpack_require__(/*! @dp/owl */ "./node_modules/@dp/owl/lib/index.js");
            this._owl.config({
                project: 'IM-Web-SDK',
                devMode: userData_1.default.get('env') === constant_1.ENV.ONLINE ? false : true,
                autoCatch: {
                    ajax: false,
                    page: false,
                    js: false,
                    resource: false,
                    console: false,
                    pv: true
                }
            });
            //     // 注意假如sdk项目中依赖owl的版本大于1.9.2需要用下面这种方式初始化（目前sdk依赖的owl版本写死成了1.9.2-1），不然会导致业务方的自定义上报不能用，详细见：https://km.sankuai.com/custom/onecloud/page/253147798#id-WebSDK%E5%92%8CWeb%E7%BB%84%E4%BB%B6%E7%9A%84Owl%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95
            //     if (window.Owl && window.Owl.OWL) {
            //         this._owl = new window.Owl.OWL({
            //             project: 'IM-Web-SDK',
            //             devMode: userData.get('env') === ENV.ONLINE ? false : true,
            //       })
            //   }
        }
    };
    OwlController.prototype.send = function (_a) {
        var _b = _a.name, name = _b === void 0 ? '' : _b, value = _a.value, _c = _a.tag, tag = _c === void 0 ? null : _c;
        if ( true && this._owl) {
            if (this._extendObject && this._extendObject.send) {
                // 调用外部对象的上报能力
                this._extendObject.send({ name: name, value: value, tag: tag });
            }
            var metric = this._owl.MetricManager();
            this._clientInformation = clientInfo_1.default.getClientInfo();
            metric.setTags(__assign({ appId: userData_1.default.get('appId'), pt: this._clientInformation.pt, os: this._clientInformation.os }, tag));
            if (metric && name) {
                metric.setMetric(name, value);
            }
        }
    };
    return OwlController;
}());
exports.default = new OwlController();


//# sourceURL=webpack://MTDX/./src/core/utils/owlController.ts?